﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;
using System.Windows;
using System.Windows.Media.Effects;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Documents;

namespace CommomFunctions
{
    public struct TraceInformation
    {
        private string frase;
        private Brush cor;

        public void setInformation(string frase, Brush cor)
        {
            this.frase = frase;
            this.cor = cor;
        }

        public string fraseContent
        {
            get
            {
                return this.frase;
            }
        }

        public Brush corContent
        {
            get
            {
                return this.cor;
            }
        }
    }

    public class Trace
    {
        public RichTextBox txtTrace = new RichTextBox();

        public Trace()
        {
            
        }

        public void criaTrace(Grid grid, int coluna, int colunaSpan, int linha, int linhaSpan, Thickness margem, int altura, int larguraMaxima)
        {
            grid.Children.Add(txtTrace);
            Grid.SetColumn(txtTrace, coluna);
            Grid.SetColumnSpan(txtTrace, colunaSpan);
            Grid.SetRow(txtTrace, linha);
            Grid.SetRowSpan(txtTrace, linhaSpan);

            txtTrace.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            txtTrace.VerticalAlignment = VerticalAlignment.Bottom;
            txtTrace.HorizontalAlignment = HorizontalAlignment.Left;
            txtTrace.IsHitTestVisible = true;
            txtTrace.IsReadOnly = true;
            txtTrace.Background = Brushes.Black;
            txtTrace.BorderBrush = Brushes.YellowGreen;
            txtTrace.BorderThickness = new Thickness(3);

            txtTrace.Margin = margem;
            txtTrace.Height = altura;
            txtTrace.MaxWidth = larguraMaxima;
        }

        public void writeTrace(string frase, Brush cor)
        {
            Paragraph para = new Paragraph();
            para.Foreground = cor;

            para.Inlines.Add(new Run(frase));

            this.txtTrace.ScrollToEnd();

            para.FontSize = 15.0;
            para.LineHeight = 12.0;
            para.LineStackingStrategy = LineStackingStrategy.BlockLineHeight;

            this.txtTrace.Document.Blocks.InsertBefore(txtTrace.Document.Blocks.LastBlock, para);
        }
    }
}
